<?php
	session_start();
	//SQL LOGIN
	$username="pepgsou_manix";
	$password="pygrace";
	$database="pepgsou_math";
	$hostname="localhost";
	mysql_connect($hostname,$username,$password);
	@mysql_select_db($database) or die( "Unable to select database");
	$nm = mysql_query("SELECT * FROM teachers WHERE username='$un' AND password='$pw'");
	$correctLogin = (mysql_numrows($nm));
	if ($correctLogin==0)
	{	
		
		echo "<html><head><title>Wrong username or password</title><meta http-equiv=\"refresh\" content=\"5;url=index.php\"><body background=\"img/lines.bmp\">";
		echo "<center><b><font color=\"red\">Wrong username or password";
		echo "<br><br><center><b>You will be redirected in 5 seconds. If you aren't click <a href=\"index.php\">here</a>.";
		die("</font></b></center></body></html>");
	} else {
		echo "<html><head><title>Signing in...</title>";
		echo "<meta http-equiv=\"refresh\" content=\"5;url=index.php\">";
		echo "</head>";
		echo "<body background=\"img/lines.bmp\">";
		echo "<center><b>Logged in!</b></center>";
		echo "<br><br><center><b>You will be redirected in 5 seconds.<br>If you aren't click <a href=\"index.php\">here</a>.";
	
		$_SESSION['username']=$un;
		$_SESSION['password']=mysql_result($nm, 0, "password");

	}
	mysql_close();
	
	
	mysql_close();
	//HTML WRITE
	echo "</body>";
	echo "</html>";
?>